import org.junit.jupiter.api.Test;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

import static org.junit.Assert.assertEquals;


public class NGuessNumberTest {
    class generateAnswerTest {
        @Test
        void generateAnswer() {
            int a = 4;
            NGuessNumber nGuessNumber = new NGuessNumber();
            assertEquals(a, nGuessNumber.generateAnswer().length);
            System.out.println("数字为4个，正确");
            int num[] = nGuessNumber.generateAnswer();
            boolean flag = false;
            int numsize = 0;
            for (int i = 0; i < a; i++) {
                if (num[i] >= 0 && num[i] <= 9) {
                    numsize = 1;
                } else {
                    numsize = 0;
                }
                for (int l = 0; l <= i; l++) {
                    if (i != l) {
                        if (num[i] == num[l]) {
                            flag = false;
                        } else {
                            flag = true;
                        }
                    }
                }
            }
            assertEquals(true, flag);
            System.out.println("无重复数字，正确");
            assertEquals(1, numsize);
            System.out.println("数字都在0-9之间，正确");
        }
    }
    class getPlayerInputTest{
        @Test
        void getPlayerInput(){
            int nimsize=4;
            NGuessNumber nGuessNumber=new NGuessNumber();
            assertEquals(nimsize,nGuessNumber.guesslist.length);
            System.out.println("用户输入的字数为4个，正确");

        }
    }

}
